<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/js-cookie@3.0.1/dist/js.cookie.min.js"></script>
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
    <script src="vue.js"></script>
    <script src="VueTest.js"></script>
    <style>
        .comment{
            width: 200px;
            height: 100px;
            background-color: beige;
        }
        .comment .commentContent{
            width: 200px;
            height: 70px;
            background-color: bisque;
        }
        .comment .commentGood{
            width: 50px;
            height: 20px;
            background-color: blueviolet;
        }
    </style>
</head>
<body>
    <div id="app">
        <p>
            {{message}}
        </p>
        游戏名: {{game.gameName}}<br>
        游戏描述: {{game.gameDetail}} <br>
        游戏价格: {{game.gamePrice}}<br>
        游戏发行时间: {{game.gameRelease}} <br>
        游戏评价:{{game.gameReview}} <br>
        游戏发行商:{{game.gamePublisher}} <br>
        游戏状态: {{game.gameState}} <br> 
        <div>
            <div v-for="comment in gameComment" class="comment" :id="'c_'+comment.commentId">
                <div class="commentContent">
                    {{comment.commentContent}}
                </div>
                <!-- 点赞数,用户点击该区域,发送点赞请求 -->
                <div class="commentGood" :id="'c_g_'+comment.commentId" @click="_greatComment($event)">
                    {{comment.commentGood}}
                </div>
            </div>
        </div>
    </div>
    <script>
        
      let gameId = Cookies.get("gameId");
      
      let vm = new Vue({
          el:"#app",
          data:{
              message:"le",
              game:{},
              gameComment:[]
          },
          created(){
              let this_ = this;
              //获取游戏信息
              gameInfo(gameId).then(resp=>{
                let resultEntity = resp.data;
                this_.game = resultEntity.data;
                console.log(this_.game);
              });
              let page = 1;
              console.log(gameId)
              //根据游戏id获取游戏评论
              gameComment(page,gameId).then(resp=>{
                let resultEntity = resp.data;
                this_.gameComment = resultEntity.data;
                console.log(this_.gameComment);
              })
          },
          methods:{
              //点赞操作
            _greatComment($event){
                console.log(event.target.id);
                let c_g_commentId = event.target.id
                let commentId = c_g_commentId.slice(4);
                console.log(commentId);
                //发送点赞请求
                greatComment(commentId).then(resp=>{
                    console.log(resp.data);
                });
            }
          }
      })    
    </script>
    
    
</body>
</html>